﻿#region References
using System;
using System.Net;

using Autumoon.IPInformer.Fundamental;
#endregion

namespace Autumoon.IPInformer.ModuleLayer
{
    public static class IPManager
    {

        #region Fields and Properties
        #endregion

        #region Constructors
        #endregion

        #region Public Methods
        public static IPProperty GetIP(string publicIPCheckAddress)
        {
            return new IPProperty() { InternalIP = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString(), PublicIP = GetPublicIP(publicIPCheckAddress), UpdateDateTime = DateTime.Now };
        }
        #endregion

        #region Internal Methods
        #endregion

        #region Protected Methods
        #endregion

        #region Private Methods
        private static string GetPublicIP(string publicIPCheckAddress)
        {
            using (WebClient wc = new WebClient())
            {
                return wc.DownloadString(publicIPCheckAddress);
            }
        }
        #endregion

        #region Delegates and Events
        #endregion
    }
}